import request from './request'

export interface Order {
  id: number
  totalAmount: number
  status: 'PENDING' | 'PAID' | 'SHIPPED' | 'COMPLETED'
  createdAt: string
  items: Array<{
    id: number
    quantity: number
    book: {
      id: number
      title: string
      price: number
    }
  }>
}

export const getOrders = () => {
  return request({
    url: '/orders',
    method: 'get'
  })
}

export const getOrderById = (id: number) => {
  return request({
    url: `/orders/${id}`,
    method: 'get'
  })
}

export const exportOrder = (id: number, format: 'pdf' | 'excel') => {
  return request({
    url: `/orders/${id}/export`,
    method: 'get',
    params: { format },
    responseType: 'blob'
  })
} 